/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.expert.service;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Order;
import org.hibernate.criterion.Restrictions;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.chlitina.store.common.persistence.Page;
import com.chlitina.store.common.service.BaseService;
import com.chlitina.store.modules.expert.dao.SolutionFaceFoodDao;
import com.chlitina.store.modules.expert.entity.SolutionFaceCare;
import com.chlitina.store.modules.expert.entity.SolutionFaceFood;

/**
 * 方案健康食品Service
 * @author liujiang
 * @version 2014-02-10
 */
@Component
@Transactional(readOnly = true)
public class SolutionFaceFoodService extends BaseService {

	@SuppressWarnings("unused")
	private static Logger logger = LoggerFactory.getLogger(SolutionFaceFoodService.class);
	
	@Autowired
	private SolutionFaceFoodDao solutionFaceFoodDao;
	
	public SolutionFaceFood getOneByPK(Long sid,Long pid) {
		return solutionFaceFoodDao.findByPKId(sid, pid);
	}
	
	public List<SolutionFaceFood> getBySolutionFace(long SolutionFaceId,
			long locationSeason, long storeTypeId){
		return solutionFaceFoodDao.getBySolutionFace(SolutionFaceId, locationSeason, storeTypeId);
	}
	
	public Page<SolutionFaceFood> find(Page<SolutionFaceFood> page, Long solutionId) {
		DetachedCriteria dc = solutionFaceFoodDao.createDetachedCriteria();
		if (solutionId != null) {
			dc.add(Restrictions.eq("solutionFace.id", solutionId));
		}
		dc.addOrder(Order.asc("product.id"));
		return solutionFaceFoodDao.find(page, dc);
	}
	
	@Transactional(readOnly = false)
	public void save(SolutionFaceFood solutionFaceFood) {
		solutionFaceFoodDao.save(solutionFaceFood);
	}
	
	@Transactional(readOnly = false)
	public void delete(SolutionFaceFood solutionFaceFood) {
		solutionFaceFoodDao.delete(solutionFaceFood);
	}
	
}
